package com.itheima.reggie.common;

/**
 * @description:基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 * @author: yanhongwei
 * @date: 2023/5/19 16:03
 * @param:
 * @return:
 **/
public class BaseContext {
    private static ThreadLocal<Long> threadLocal=new ThreadLocal<>();

    /**
     * @description:设置值
     * @author: yanhongwei
     * @date: 2023/5/19 16:12
     * @param: [id]
     * @return: void
     **/
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    /**
     * @description:获取值
     * @author: yanhongwei
     * @date: 2023/5/19 16:12
     * @param: []
     * @return: java.lang.Long
     **/
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
